Neural network processor

ABSTRACT

A circuit for performing neural network computations for a neural network comprising a plurality of neural network layers, the circuit comprising: a matrix computation unit configured to, for each of the plurality of neural network layers: receive a plurality of weight inputs and a plurality of activation inputs for the neural network layer, and generate a plurality of accumulated values based on the plurality of weight inputs and the plurality of activation inputs; and a vector computation unit communicatively coupled to the matrix computation unit and configured to, for each of the plurality of neural network layers: apply an activation function to each accumulated value generated by the matrix computation unit to generate a plurality of activated values for the neural network layer.

CROSS REFERENCE TO RELATED APPLICATIONS

This application is a non-provisional of and claims priority to U.S.Provisional Patent Application No. 62/164,931, filed on May 21, 2015,the entire contents of which are hereby incorporated by reference.

BACKGROUND

This specification relates to computing neural network inferences inhardware.

Neural networks are machine learning models that employ one or morelayers of models to generate an output, e.g., a classification, for areceived input. Some neural networks include one or more hidden layersin addition to an output layer. The output of each hidden layer is usedas input to the next layer in the network, i.e., the next hidden layeror the output layer of the network. Each layer of the network generatesan output from a received input in accordance with current values of arespective set of parameters.

SUMMARY

In general, this specification describes a special-purpose hardwarecircuit that computes neural network inferences.

In general, one innovative aspect of the subject matter described inthis specification can be embodied in a circuit for performing neuralnetwork computations for a neural network comprising a plurality ofneural network layers, the circuit comprising: a matrix computation unitconfigured to, for each of the plurality of neural network layers:receive a plurality of weight inputs and a plurality of activationinputs for the neural network layer, and generate a plurality ofaccumulated values based on the plurality of weight inputs and theplurality of activation inputs; and a vector computation unitcommunicatively coupled to the matrix computation unit and configuredto, for each of the plurality of neural network layers: apply anactivation function to each accumulated value generated by the matrixcomputation unit to generate a plurality of activated values for theneural network layer.

Implementations can include one or more of the following features. Aunified buffer communicatively coupled to the matrix computation unitand the vector computation unit, where the unified buffer is configuredto receive and store output from the vector computation unit, and theunified buffer is configured to send the received output as input to thematrix computation unit. A sequencer configured to receive instructionsfrom a host device and generate a plurality of control signals from theinstructions, where the plurality of control signals control dataflowthrough the circuit; and a direct memory access engine communicativelycoupled to the unified buffer and the sequencer, where the direct memoryaccess engine is configured to send the plurality of activation inputsto the unified buffer, where the unified buffer is configured to sendthe plurality of activation inputs to the matrix computation unit, andwhere the direct memory access engine is configured to read result datafrom the unified buffer. A memory unit configured to send the pluralityof weight inputs to the matrix computation unit, and where the directmemory access engine is configured to send the plurality of weightinputs to the memory unit. The matrix computation unit is configured asa two dimensional systolic array comprising a plurality of cells. Theplurality of weight inputs is shifted through a first plurality of cellsalong a first dimension of the systolic array, and where the pluralityof activation inputs is shifted through a second plurality of cellsalong a second dimension of the systolic array. For a given layer in theplurality of layers, a count of the plurality of activation inputs isgreater than a size of the second dimension of the systolic array, andwhere the systolic array is configured to: divide the plurality ofactivation inputs into portions, where each portion has a size less thanor equal to the size of the second dimension; generating, for eachportion, a respective portion of accumulated values; and combining eachportion of accumulated values to generate a vector of accumulated valuesfor the given layer. For a given layer in the plurality of layers, acount of the plurality of weight inputs is greater than a size of thefirst dimension of the systolic array, and where the systolic array isconfigured to: divide the plurality of weight inputs into portions,where each portion has a size less than or equal to the size of thefirst dimension; generating, for each portion, a respective portion ofaccumulated values; and combining each portion of accumulated values togenerate a vector of accumulated values for the given layer. Each cellin the plurality of cells comprises: a weight register configured tostore a weight input; an activation register configured to store anactivation input and configured to send the activation input to anotheractivation register in a first adjacent cell along the second dimension;a sum-in register configured to store a previously summed value;multiplication circuitry communicatively coupled to the weight registerand the activation register, where the multiplication circuitry isconfigured to output a product of the weight input and the activationinput; and summation circuitry communicatively coupled to themultiplication circuitry and the sum-in register, where the summationcircuitry is configured to output a sum of the product and thepreviously summed value, and where the summation circuitry is configuredto send the sum to another sum-in register in a second adjacent cellalong the first dimension. One or more cells in the plurality of cellsare each configured to store the respective sum in a respectiveaccumulator unit, where the respective sum is an accumulated value. Thefirst dimension of the systolic array corresponds to columns of thesystolic array, and where the second dimension of the systolic arraycorresponds to rows of the systolic array. The vector computation unitnormalizes each activated value to generate a plurality of normalizedvalues. The vector computation unit pools one or more activated valuesto generate a plurality of pooled values.

Particular embodiments of the subject matter described in thisspecification can be implemented so as to realize one or more of thefollowing advantages. Implementing a neural network processor inhardware improves efficiency, e.g., increase speed and throughput andreduce power and cost, over implementations in software. This can beuseful for inference applications. Integrating components of the neuralnetwork processor into one circuit allows inferences to be computedwithout incurring penalties of off-chip communication. Additionally, thecircuit can process neural network layers that have a number of inputs,e.g., a number of weight inputs or a number of activation inputs, largerthan a size of a dimension of a matrix computation unit within thecircuit. For example, the circuit can process a large number of weightinputs per neuron of the neural network.

The details of one or more embodiments of the subject matter of thisspecification are set forth in the accompanying drawings and thedescription below. Other features, aspects, and advantages of thesubject matter will become apparent from the description, the drawings,and the claims.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a flow diagram of an example method for performing acomputation for a given layer of a neural network.

FIG. 2 shows an example neural network processing system.

FIG. 3 shows an example architecture including a matrix computationunit.

FIG. 4 shows an example architecture of a cell inside a systolic array.

FIG. 5 shows an example architecture of a vector computation unit.

FIG. 6 is a flow diagram of another example process for performing,using a systolic array, the computation for a given neural network layerhaving more activation inputs than rows in the systolic array.

Like reference numbers and designations in the various drawings indicatelike elements.

DETAILED DESCRIPTION

A neural network having multiple layers can be used to computeinferences. For example, given an input, the neural network can computean inference for the input. The neural network computes this inferenceby processing the input through each of the layers of the neuralnetwork. In particular, the layers of the neural network are arranged ina sequence, each with a respective set of weights. Each layer receivesan input and processes the input in accordance with the set of weightsfor the layer to generate an output.

Therefore, in order to compute an inference from a received input, theneural network receives the input and processes it through each of theneural network layers in the sequence to generate the inference, withthe output from one neural network layer being provided as input to thenext neural network layer. Data inputs to a neural network layer, e.g.,either the input to the neural network or the outputs of the layer belowthe layer in the sequence, to a neural network layer can be referred toas activation inputs to the layer.

In some implementations, the layers of the neural network are arrangedin a directed graph. That is, any particular layer can receive multipleinputs, multiple outputs, or both. The layers of the neural network canalso be arranged such that an output of a layer can be sent back as aninput to a previous layer.

FIG. 1 is a flow diagram of an example process 100 for performing acomputation for a given layer of a neural network using aspecial-purpose hardware circuit. For convenience, the method 100 willbe described with respect to a system having one or more circuits thatperforms the method 100. The method 100 can be performed for each layerof the neural network in order to compute an inference from a receivedinput.

The system receives sets of weight inputs (step 102) and sets ofactivation inputs (step 104) for the given layer. The sets of weightinputs and the sets of activation inputs can be received from dynamicmemory and a unified buffer, respectively, of the special-purposehardware circuit. In some implementations, both the sets of weightinputs and the sets of activation inputs can be received from theunified buffer.

The system generates accumulated values from the weight inputs and theactivation inputs using a matrix multiplication unit of thespecial-purpose hardware circuit (step 106). In some implementations,the accumulated values are dot products of the sets of weight inputs andthe sets of activation inputs. That is, for one set of weights, thesystem can multiply each weight input with each activation input and sumthe products together to form an accumulated value. The system can thencompute dot products of other set of weights with other sets ofactivation inputs.

The system can generate a layer output from the accumulation values(step 108) using a vector computation unit of the special-purposehardware circuit. In some implementations, the vector computation unitapplies an activation function to the accumulated values, which will bedescribed further below in reference to FIG. 5. The output of the layercan be stored in the unified buffer for use as an input to a subsequentlayer in the neural network or can be used to determine the inference.The system finishes processing the neural network when a received inputhas been processed through each layer of the neural network to generatethe inference for the received input.

FIG. 2 shows an example special-purpose integrated circuit 200 forperforming neural network computations. The system 200 includes a hostinterface 202. The host interface 202 can receive instructions thatinclude parameters for a neural network computation. The parameters caninclude at least one or more of the following: how many layers should beprocessed, corresponding sets of weight inputs for each layer of thelayer, an initial set of activation inputs, i.e., the input to theneural network from which the inference is to be computed, correspondinginput and output sizes of each layer, a stride value for the neuralnetwork computation, and a type of layer to be processed, e.g., aconvolutional layer or a fully connected layer.

The host interface 202 can send the instructions to a sequencer 206,which converts the instructions into low level control signals thatcontrol the circuit to perform the neural network computations. In someimplementations, the control signals regulate dataflow in the circuit,e.g., how the sets of weight inputs and the sets of activation inputsflow through the circuit. The sequencer 206 can send the control signalsto a unified buffer 208, a matrix computation unit 212, and a vectorcomputation unit 214. In some implementations, the sequencer 206 alsosends control signals to a direct memory access engine 204 and dynamicmemory 210. In some implementations, the sequencer 206 is a processorthat generates clock signals. The sequencer 206 can use timing of theclock signals to, at appropriate times, send the control signals to eachcomponent of the circuit 200. In some other implementations, the hostinterface 202 passes in a clock signal from an external processor.

The host interface 202 can send the sets of weight inputs and theinitial set of activation inputs to the direct memory access engine 204.The direct memory access engine 204 can store the sets of activationinputs at the unified buffer 208. In some implementations, the directmemory access stores the sets of weights to dynamic memory 210, whichcan be a memory unit. In some implementations, the dynamic memory islocated off of the circuit.

The unified buffer 208 is a memory buffer. It can be used to store theset of activation inputs from the direct memory access engine 204 andoutputs of the vector computation unit 214. The vector computation unitwill be described in more detail below with reference to FIG. 5. Thedirect memory access engine 204 can also read the outputs of the vectorcomputation unit 214 from the unified buffer 208.

The dynamic memory 210 and the unified buffer 208 can send the sets ofweight inputs and the sets of activation inputs, respectively, to thematrix computation unit 212. In some implementations, the matrixcomputation unit 212 is a two-dimensional systolic array. The matrixcomputation unit 212 can also be a one-dimensional systolic array orother circuitry that can perform mathematical operations, e.g.,multiplication and addition. In some implementations, the matrixcomputation unit 212 is a general purpose matrix processor.

The matrix computation unit 212 can process the weight inputs and theactivation inputs and provide a vector of outputs to the vectorcomputation unit 214. In some implementations, the matrix computationunit sends the vector of outputs to the unified buffer 208, which sendsthe vector of outputs to the vector computation unit 214. The vectorcomputation unit can process the vector of outputs and store a vector ofprocessed outputs to the unified buffer 208. The vector of processedoutputs can be used as activation inputs to the matrix computation unit212, e.g., for use in a subsequent layer in the neural network. Thematrix computation unit 212 and the vector computation unit 214 will bedescribed in more detail below with reference to FIG. 3 and FIG. 5,respectively.

FIG. 3 shows an example architecture 300 including a matrix computationunit. The matrix computation unit is a two-dimensional systolic array306. The two-dimensional systolic array 306 can be a square array. Thearray 306 includes multiple cells 304. In some implementations, a firstdimension 320 of the systolic array 306 corresponds to columns of cellsand a second dimension 322 of the systolic array 306 corresponds to rowsof cells. The systolic array can have more rows than columns, morecolumns than rows, or an equal number of columns and rows.

In the illustrated example, value loaders 302 send activation inputs torows of the array 306 and a weight fetcher interface 308 sends weightinputs to columns of the array 306. In some other implementations,however, activation inputs are transferred to the columns and weightinputs are transferred to the rows of the array 306.

The value loaders 302 can receive the activation inputs from a unifiedbuffer, e.g., the unified buffer 208 of FIG. 2. Each value loader cansend a corresponding activation input to a distinct left-most cell ofthe array 306. The left-most cell can be a cell along a left-most columnof the array 306. For example, value loader 312 can send an activationinput to cell 314. The value loader can also send the activation inputto an adjacent value loader, and the activation input can be used atanother left-most cell of the array 306. This allows activation inputsto be shifted for use in another particular cell of the array 306.

The weight fetcher interface 308 can receive the weight input from amemory unit, e.g., the dynamic memory 210 of FIG. 2. The weight fetcherinterface 308 can send a corresponding weight input to a distincttop-most cell of the array 306. The top-most cell can be a cell along atop-most row of the array 306. For example, the weight fetcher interface308 can send weight inputs to cells 314 and 316.

In some implementations, a host interface, e.g., the host interface 202of FIG. 2, shifts activation inputs throughout the array 306 along onedimension, e.g., to the right, while shifting weight inputs throughoutthe array 306 along another dimension, e.g., to the bottom. For example,over one clock cycle, the activation input at cell 314 can shift to anactivation register in cell 316, which is to the right of cell 314.Similarly, the weight input at cell 316 can shift to a weight registerat cell 318, which is below cell 314.

On each clock cycle, each cell can process a given weight input and agiven activation input to generate an accumulated output. Theaccumulated output can also be passed to an adjacent cell along the samedimension as the given weight input. An individual cell is describedfurther below with reference FIG. 4.

The accumulated output can be passed along the same column as the weightinput, e.g., towards the bottom of the column in the array 306. In someimplementations, at the bottom of each column, the array 306 can includeaccumulator units 310 that store and accumulate each accumulated outputfrom each column when performing calculations with layers having moreweight inputs than columns or layers having more activation inputs thanrows. In some implementations, each accumulator unit stores multipleparallel accumulations. This will be described further below withreference to FIG. 6. The accumulator units 310 can accumulate eachaccumulated output to generate a final accumulated value. The finalaccumulated value can be transferred to a vector computation unit, e.g.,the vector computation unit 502 of FIG. 5. In some otherimplementations, the accumulator units 310 passes the accumulated valuesto the vector computation unit without performing any accumulations whenprocessing layers with fewer weight inputs than columns or layers havingfewer activating inputs than rows.

FIG. 4 shows an example architecture 400 of a cell inside a systolicarray, e.g., the systolic array 306 of FIG. 3.

The cell can include an activation register 406 that stores anactivation input. The activation register can receive the activationinput from a left adjacent cell, i.e., an adjacent cell located to theleft of the given cell, or from a unified buffer, depending on theposition of the cell within the systolic array. The cell can include aweight register 402 that stores a weight input. The weight input can betransferred from a top adjacent cell or from a weight fetcher interface,depending on the position of the cell within the systolic array. Thecell can also include a sum in register 404. The sum in register 404 canstore an accumulated value from the top adjacent cell. Multiplicationcircuitry 408 can be used to multiply the weight input from the weightregister 402 with the activation input from the activation register 406.The multiplication circuitry 408 can output the product to summationcircuitry 410.

The summation circuitry can sum the product and the accumulated valuefrom the sum in register 404 to generate a new accumulated value. Thesummation circuitry 410 can then send the new accumulated value toanother sum in register located in a bottom adjacent cell. The newaccumulated value can be used as an operand for a summation in thebottom adjacent cell.

The cell can also shift the weight input and the activation input toadjacent cells for processing. For example, the weight register 402 cansend the weight input to another weight register in the bottom adjacentcell. The activation register 406 can send the activation input toanother activation register in the right adjacent cell. Both the weightinput and the activation input can therefore be reused by other cells inthe array at a subsequent clock cycle.

In some implementations, the cell also includes a control register. Thecontrol register can store a control signal that determines whether thecell should shift either the weight input or the activation input toadjacent cells. In some implementations, shifting the weight input orthe activation input takes one or more clock cycles. The control signalcan also determine whether the activation input or weight inputs aretransferred to the multiplication circuitry 408, or can determinewhether the multiplication circuitry 408 operates on the activation andweight inputs. The control signal can also be passed to one or moreadjacent cells, e.g., using a wire.

In some implementations, weights are pre-shifted into a weight pathregister 412. The weight path register 412 can receive the weight input,e.g., from a top adjacent cell, and transfer the weight input to theweight register 402 based on the control signal. The weight register 402can statically store the weight input such that as activation inputs aretransferred to the cell, e.g., through the activation register 406, overmultiple clock cycles, the weight input remains within the cell and isnot transferred to an adjacent cell. Therefore, the weight input can beapplied to multiple activation inputs, e.g., using the multiplicationcircuitry 408, and respective accumulated values can be transferred toan adjacent cell.

FIG. 5 shows an example architecture 500 of a vector computation unit502. The vector computation unit 502 can receive a vector of accumulatedvalues from a matrix computation unit, e.g., the matrix computation unitdescribed in reference to FIG. 2.

The vector computation unit 502 can process the vector of accumulatedvalues at the activation unit 404. In some implementations, theactivation unit includes circuitry that applies a non-linear function toeach accumulated value to generate activation values. For example, thenon-linear function can be tanh(x), where x is an accumulated value.

Optionally, the vector computation unit 502 can normalize the activationvalues in a normalization unit 506 that generates normalized values fromthe activation values.

Also optionally, the vector computation unit 502 can pool values, eitheractivation values or normalization values, using a pooling unit 508. Thepooling unit 508 can apply an aggregation function to one or more of thenormalized values to generate pooled values. In some implementations,the aggregation functions are functions that return a maximum, minimum,or average of the normalized values or of a subset of the normalizedvalues.

Control signals 510 can be transferred, e.g., by the sequencer 206 ofFIG. 2, and can regulate how the vector computation unit 502 processesthe vector of accumulated values. That is, the control signals 510 canregulate whether the activation values are pooled, normalized, or both.The control signals 510 can also specify the activation, normalization,or pooling functions, as well as other parameters for normalization andpooling, e.g., a stride value.

The vector computation unit 502 can send values, e.g., activationvalues, normalized values, or pooled values, to a unified buffer, e.g.,the unified buffer 208 of FIG. 2.

In some implementations, the pooling unit 508 receives the activationvalues instead of the normalization unit 506, and the pooling unit 508sends the pooled values to the normalization unit 506, which generatesnormalized values to be stored in the unified buffer.

FIG. 6 is a flow diagram of example process for performing, using asystolic array, the computation for a given neural network layer havingmore activation inputs than rows in the systolic array. For convenience,the process 600 will be described with respect to a system that performsthe process 600. In some implementations, a host interface or asequencer performs the process 600, e.g., the host interface 202 or thesequencer 206, respectively, of FIG. 2. In some other implementations,the host interface receives instructions from an external processor thatperforms the process 600.

As described above, each layer can have multiple sets of activationinputs and each set of weight inputs can be transferred to cells atdistinct rows of the array. In some implementations, some layers of theneural network have more sets of activation inputs than there are rowsof the array.

The system can determine, e.g., using a comparator, whether there aremore sets of activation inputs for the given neural network layer thanthere are rows in the systolic array. In some implementations, thesystem makes the determination at compile time. A set of activationinputs can correspond to the activation inputs provided to a single rowof the array.

If there are more rows than sets of activation inputs (step 602), thesystem can generate accumulated values as described above in thesystolic array 306 of FIG. 3 (step 604).

If there are more sets of activation inputs to be processed than thereare rows in the array (step 602), the system can divide the sets ofactivation inputs into portions so that each portion has a size lessthan or equal to a number of rows in the array (step 606).

The system then can generate, for each portion of activation inputs, aportion of accumulated values (step 608). An accumulated value can be asum of products of activation and weight inputs to cells along a givencolumn, e.g., as described in systolic array 306 of FIG. 3. Each portionof accumulated values can be stored in a buffer until all portions ofactivation inputs have been processed. The buffer can be a buffer inaccumulator units 310 of FIG. 3, a buffer in the systolic array, or theunified buffer 208 of FIG. 2.

The system can then combine all portions of accumulated values into avector of accumulated values (step 610). In particular, the system canaccess the buffer of previously stored portions of accumulated valuesand accumulate, e.g., using accumulator units 310 of FIG. 3, theaccumulated values to generate a vector of the accumulated values. Thesystem can send the vector of the accumulated values to a vectorcomputation unit, e.g., the vector computation unit 214 of FIG. 2.

For example, if there are 256 rows in the array and there are 300 setsof activation inputs to process at a given layer, the system cangenerate 256 final accumulated values from 256 sets of activation inputsfor complete utilization of the systolic array and store the 256 finalaccumulated values in a buffer. The system can then generate 44 finalaccumulated values from the 44 remainder sets of activation inputs.Finally, the system can combine all 300 final accumulated values to forma vector and send the vector to the vector computation unit.

If there are more sets of weight inputs than columns to the array, thesystem can perform similar operations. That is, the system can dividethe sets of weight inputs into portions having fewer sets of weightinputs than a number of columns in the array, generate accumulatedvalues for each portion, and combine the accumulated values into avector for use in the vector computation unit. In some implementations,instead of comparing the number of sets of weight inputs with the numberof columns in the array, the system can compare the number ofaccumulated values with the number of columns in the array.

Although the system has been described with weight inputs beingtransferred to columns of the array and activation inputs beingtransferred to rows of the array, in some implementations, the weightinputs are transferred to rows of the array and the activation inputsare transferred to columns of the array.

Although the hardware is described to be for computing inferences, thehardware can be used for one or more of the following: convolutional orfully-connected neural network training, linear or logistic regression,clustering, e.g., k-means clustering, video-encoding, and imageprocessing.

Embodiments of the subject matter and the functional operationsdescribed in this specification can be implemented in digital electroniccircuitry, in tangibly-embodied computer software or firmware, incomputer hardware, including the structures disclosed in thisspecification and their structural equivalents, or in combinations ofone or more of them. Embodiments of the subject matter described in thisspecification can be implemented as one or more computer programs, i.e.,one or more modules of computer program instructions encoded on atangible non transitory program carrier for execution by, or to controlthe operation of, data processing apparatus. Alternatively or inaddition, the program instructions can be encoded on an artificiallygenerated propagated signal, e.g., a machine-generated electrical,optical, or electromagnetic signal, that is generated to encodeinformation for transmission to suitable receiver apparatus forexecution by a data processing apparatus. The computer storage mediumcan be a machine-readable storage device, a machine-readable storagesubstrate, a random or serial access memory device, or a combination ofone or more of them.

The term “data processing apparatus” encompasses all kinds of apparatus,devices, and machines for processing data, including by way of example aprogrammable processor, a computer, or multiple processors or computers.The apparatus can include special purpose logic circuitry, e.g., an FPGA(field programmable gate array) or an ASIC (application specificintegrated circuit). The apparatus can also include, in addition tohardware, code that creates an execution environment for the computerprogram in question, e.g., code that constitutes processor firmware, aprotocol stack, a database management system, an operating system, or acombination of one or more of them.

A computer program (which may also be referred to or described as aprogram, software, a software application, a module, a software module,a script, or code) can be written in any form of programming language,including compiled or interpreted languages, or declarative orprocedural languages, and it can be deployed in any form, including as astandalone program or as a module, component, subroutine, or other unitsuitable for use in a computing environment. A computer program may, butneed not, correspond to a file in a file system. A program can be storedin a portion of a file that holds other programs or data, e.g., one ormore scripts stored in a markup language document, in a single filededicated to the program in question, or in multiple coordinated files,e.g., files that store one or more modules, sub programs, or portions ofcode. A computer program can be deployed to be executed on one computeror on multiple computers that are located at one site or distributedacross multiple sites and interconnected by a communication network.

The processes and logic flows described in this specification can beperformed by one or more programmable computers executing one or morecomputer programs to perform functions by operating on input data andgenerating output. The processes and logic flows can also be performedby, and apparatus can also be implemented as, special purpose logiccircuitry, e.g., an FPGA (field programmable gate array) or an ASIC(application specific integrated circuit).

Computers suitable for the execution of a computer program include, byway of example, can be based on general or special purposemicroprocessors or both, or any other kind of central processing unit.Generally, a central processing unit will receive instructions and datafrom a read only memory or a random access memory or both. The essentialelements of a computer are a central processing unit for performing orexecuting instructions and one or more memory devices for storinginstructions and data. Generally, a computer will also include, or beoperatively coupled to receive data from or transfer data to, or both,one or more mass storage devices for storing data, e.g., magnetic,magneto optical disks, or optical disks. However, a computer need nothave such devices. Moreover, a computer can be embedded in anotherdevice, e.g., a mobile telephone, a personal digital assistant (PDA), amobile audio or video player, a game console, a Global PositioningSystem (GPS) receiver, or a portable storage device, e.g., a universalserial bus (USB) flash drive, to name just a few.

Computer readable media suitable for storing computer programinstructions and data include all forms of nonvolatile memory, media andmemory devices, including by way of example semiconductor memorydevices, e.g., EPROM, EEPROM, and flash memory devices; magnetic disks,e.g., internal hard disks or removable disks; magneto optical disks; andCD ROM and DVD-ROM disks. The processor and the memory can besupplemented by, or incorporated in, special purpose logic circuitry.

To send for interaction with a user, embodiments of the subject matterdescribed in this specification can be implemented on a computer havinga display device, e.g., a CRT (cathode ray tube) or LCD (liquid crystaldisplay) monitor, for displaying information to the user and a keyboardand a pointing device, e.g., a mouse or a trackball, by which the usercan send input to the computer. Other kinds of devices can be used tosend for interaction with a user as well; for example, feedback providedto the user can be any form of sensory feedback, e.g., visual feedback,auditory feedback, or tactile feedback; and input from the user can bereceived in any form, including acoustic, speech, or tactile input. Inaddition, a computer can interact with a user by sending documents toand receiving documents from a device that is used by the user; forexample, by sending web pages to a web browser on a user's client devicein response to requests received from the web browser.

Embodiments of the subject matter described in this specification can beimplemented in a computing system that includes a back end component,e.g., as a data server, or that includes a middleware component, e.g.,an application server, or that includes a front end component, e.g., aclient computer having a graphical user interface or a Web browserthrough which a user can interact with an implementation of the subjectmatter described in this specification, or any combination of one ormore such back end, middleware, or front end components. The componentsof the system can be interconnected by any form or medium of digitaldata communication, e.g., a communication network. Examples ofcommunication networks include a local area network (“LAN”) and a widearea network (“WAN”), e.g., the Internet.

The computing system can include clients and servers. A client andserver are generally remote from each other and typically interactthrough a communication network. The relationship of client and serverarises by virtue of computer programs running on the respectivecomputers and having a client-server relationship to each other.

While this specification contains many specific implementation details,these should not be construed as limitations on the scope of anyinvention or of what may be claimed, but rather as descriptions offeatures that may be specific to particular embodiments of particularinventions. Certain features that are described in this specification inthe context of separate embodiments can also be implemented incombination in a single embodiment. Conversely, various features thatare described in the context of a single embodiment can also beimplemented in multiple embodiments separately or in any suitablesubcombination. Moreover, although features may be described above asacting in certain combinations and even initially claimed as such, oneor more features from a claimed combination can in some cases be excisedfrom the combination, and the claimed combination may be directed to asubcombination or variation of a subcombination.

Similarly, while operations are depicted in the drawings in a particularorder, this should not be understood as requiring that such operationsbe performed in the particular order shown or in sequential order, orthat all illustrated operations be performed, to achieve desirableresults. In certain circumstances, multitasking and parallel processingmay be advantageous. Moreover, the separation of various system modulesand components in the embodiments described above should not beunderstood as requiring such separation in all embodiments, and itshould be understood that the described program components and systemscan generally be integrated together in a single software product orpackaged into multiple software products.

Particular embodiments of the subject matter have been described. Otherembodiments are within the scope of the following claims. For example,the actions recited in the claims can be performed in a different orderand still achieve desirable results. As one example, the processesdepicted in the accompanying figures do not necessarily require theparticular order shown, or sequential order, to achieve desirableresults. In certain implementations, multitasking and parallelprocessing may be advantageous.

What is claimed is:
 1. A system for performing neural networkcomputations for a neural network having a plurality of neural networklayers, the system comprising: a hardware circuit comprising at least afirst circuit portion that includes a matrix computation unit comprisingM ×N cells, wherein M and N are positive integers that are greater thanone, and wherein each cell of the M ×N cells of the first circuitportion includes respective circuitry configured to: obtain, from anadjacent cell along a first dimension of the matrix computation unit, arespective weight input the respective weight input being a weight inputfor a neural network layer of the plurality of neural network layers;obtain, from an adjacent cell along a second dimension of the matrixcomputation unit, a respective activation input for the neural networklayer; determine a respective multiplication product based on therespective weight input and the respective activation input; determine arespective accumulated value based at least on the respectivemultiplication product; provide, to another adjacent cell along thefirst dimension of the matrix computation unit, the respectiveaccumulated value for determining an output for the neural networklayer; and provide, to an adjacent cell along the second dimension ofthe matrix computation unit, the respective activation input for theneural network layer.
 2. The system of claim 1, wherein, for each of Mcells along the first dimension, the adjacent cell along the seconddimension obtains the respective activation input from a respectivevalue loader.
 3. The system of claim 2, wherein, for each of N cellsalong the second dimension, the adjacent cell along the first dimensionobtains the respective weight input from a weight fetcher interface. 4.The system of claim 1, wherein the respective weight input is obtainedfrom the adjacent cell along the first dimension and the respectiveactivation input is obtained from the adjacent cell along the seconddimension periodically over a predetermined number of clock cycles. 5.The system of claim 1, wherein for each cell of (M−1)×N cells of the M×N cells, the respective circuitry is further configured to obtain arespective second accumulated value shifted from another cell of the M×N cells, wherein determining the respective accumulated value comprisesdetermining the respective accumulated value based at least on therespective multiplication product and the respective second accumulatedvalue.
 6. The system of claim 1, wherein determining the respectivemultiplication product comprises determining the respectivemultiplication product based on a control signal.
 7. The system of claim1, wherein, for each of N cells along the second dimension, the anotheradjacent cell long the first dimension provides one or more values to arespective accumulator unit.
 8. The system of claim 1, wherein providingthe respective accumulated value comprises providing the respectiveaccumulated value based on a control signal.
 9. The system of claim 1,wherein providing the respective activation input comprises providingthe respective activation input based on a control signal.
 10. Thesystem of claim 1, further comprising: a first memory configured toprovide activation inputs for the plurality of neural network layers;and a second memory configured to provide weight inputs for theplurality of neural network layers.
 11. The system of claim 10, whereinthe hardware circuit further comprises a second circuit portion thatincludes: vector computation circuitry configured to: determine anactivation vector based on one or more accumulated values received fromthe matrix computation unit; and provide the activation vector to thefirst memory.
 12. The system of claim 11, further comprising: sequencercircuitry configured to provide one or more control signals to the firstmemory, the second memory, the vector computation circuitry, or thematrix computation unit to control a dataflow of the system.
 13. Amethod for performing neural network computations for a neural networkhaving a plurality of neural network layers, the method comprising: foreach cell of M ×N cells of a matrix computation unit that is disposedwithin at least a first circuit portion of a hardware circuit comprisingthe neural network: obtaining, from an adjacent cell along a firstdimension of the matrix computation unit, a respective weight input fora neural network layer of the plurality of neural network layers;obtaining, from an adjacent cell along a second dimension of the matrixcomputation unit, a respective activation input for the neural networklayer; determining a respective multiplication product based on therespective weight input and the respective activation input; determininga respective accumulated value based at least on the respectivemultiplication product; providing, to another adjacent cell along thefirst dimension of the matrix computation unit, the respectiveaccumulated value for determining an output for the neural networklayer, wherein M and N are positive integers that are greater than one;and providing, to an adjacent cell along the second dimension of thematrix computation unit, the respective activation input for the neuralnetwork layer.
 14. The method of claim 13, wherein, for each of M cellsalong the first dimension, the adjacent cell along the second dimensionobtains the respective activation input from a respective value loader.15. The method of claim 14, wherein, for each of the N cells along thesecond dimension, the adjacent cell along the first dimension obtainsthe respective weight input from a weight fetcher interface.
 16. Themethod of claim 1, further comprising: for each cell of (M−1)×N cells ofthe M×N cells, obtaining a respective second accumulated value shiftedfrom another cell of the M×N cells, wherein determining the respectiveaccumulated value comprises determining the respective accumulated valuebased at least on the respective multiplication product and therespective second accumulated value.
 17. The method of claim 13,wherein, for each of N cells along the second dimension, the anotheradjacent cell long the first dimension provides one or more values to arespective accumulator unit.
 18. A matrix computation unit configured tobe disposed within at least a first circuit portion of a hardwarecircuit, the matrix computation unit for performing neural networkcomputations for a neural network having a plurality of neural networklayers, the matrix computation unit comprising M×N cells, wherein M andN are positive integers that are greater than one, and wherein each cellof the M×N cells of the first circuit portion includes respectivecircuitry configured to: obtain, from an adjacent cell along a firstdimension of the matrix computation unit, a respective weight input fora neural network layer of the plurality of neural network layers;obtain, from an adjacent cell along a second dimension of the matrixcomputation unit, a respective activation input for the neural networklayer; determine a respective multiplication product based on therespective weight input and the respective activation input; determine arespective accumulated value based at least on the respectivemultiplication product; provide, to another adjacent cell along thesecond dimension of the matrix computation unit, the respectiveaccumulated value for determining an output for the neural networklayer; and provide, to an adjacent cell along the second dimension ofthe matrix computation unit, the respective activation input for theneural network layer.
 19. The matrix computation unit of claim 18,wherein, for each of M cells along the first dimension, the adjacentcell along the second dimension obtains the respective activation inputfrom a respective value loader.
 20. The matrix computation unit of claim19, wherein, for each of the N cells along the second dimension, theadjacent cell along the first dimension obtains the respective weightinput from a weight fetcher interface.
 21. The matrix computation unitof claim 20, wherein for each cell of (M−1)×N cells of the M×N cells,the respective circuitry is further configured to obtain a respectivesecond accumulated value shifted from another cell of the M×N cells,wherein determining the respective accumulated value comprisesdetermining the respective accumulated value based at least on therespective multiplication product and the respective second accumulatedvalue.